﻿app.factory('fileUpload', ['$http', function ($http) {

    return {
        //uploadFileToUrl: function (file, uploadUrl) {
        //    var fd = new FormData();
        //    fd.append('file', file);
        //    $http.post(uploadUrl, fd, {
        //        transformRequest: angular.identity,
        //        headers: { 'Content-Type': undefined }
        //    })
        //},
        uploadFileToUrl: function (file, uploadUrl) {
            var fd = new FormData();
            fd.append('file', file);
            return $http.post(uploadUrl, fd, {
                transformRequest: angular.identity,
                headers: { 'Content-Type': undefined }
            }).then(function (result) {
                return result;
            });
        }
    };
    //this.uploadFileToUrl = function (file, uploadUrl) {
    //    debugger;
    //    var fd = new FormData();
    //    fd.append('file', file);
    //    fd.name = "test.jpg";
    //    $http.post(uploadUrl, fd, {
    //        transformRequest: angular.identity,
    //        headers: { 'Content-Type': undefined }
    //    })

    //    .success(function (data) {
    //        alert(data)
    //    })

    //    .error(function () {
    //    });
    //}
}]);